home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-03 | 28.8 KB | 1,276 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { CShTile.p }
- {}
- { Pane class for the Showwit tiles. When clicked, these tiles flip between hiding }
- { and showing a target picture. The target is a PixMap pane, and the pane is a }
- { "window" into the part of the picture concealed by the tile. The hiding side is }
- { a color icon, at the centre of the pane. We override the DrawAll method to }
- { draw only one of these panes. We use a color icon so that the hiding side of the }
- { tile automatically adapts to the correct screen depth. If Color QuickDraw is }
- { not present, then the color icon pane uses the black and white icons anyway. }
- {}
- {****************************************************}
-
-
- unit CShTile;
-
- interface
-
- uses
- ShIntf;
-
- implementation
-
- {****************************************************}
- {}
- { IShTile }
- {}
- { Construction of the Showwit Tile object. }
- {}
- {****************************************************}
-
- procedure CShTile.IShTile (anEnclosure: CView;
- aSupervisor: CShGameDirector;
- aHEncl, aVEncl: integer;
- aHSizing, aVSizing: SizingOption);
-
- var
- thePixMapPane: CPixMapPane;
- theTileLRect: LongRect;
-
- theIcon: CIconPane;
-
- begin { IShTile }
- itsPixMapPane := nil;
- itsIcon := nil;
-
- itsGameDirector := aSupervisor;
-
- IPane(anEnclosure, aSupervisor, kTileSize, kTileSize, aHEncl, aVEncl, aHSizing, aVSizing);
- SetWantsClicks(TRUE);
-
- { CShTile needs random numbers. This is a good place to initialize the random seed. }
- RandSeed := TickCount;
-
- { Create PixMap pane with offscreen bitmap and port. }
- SetLongRect(theTileLRect, 0, 0, kTileSize, kTileSize);
- new(thePixMapPane);
- thePixMapPane.IPixMapPane(SELF, SELF, kTileSize, kTileSize, 0, 0, aHSizing, aVSizing, theTileLRect, nil, TRUE);
- itsPixMapPane := thePixMapPane;
-
- new(theIcon);
- theIcon.IIconPane(SELF, SELF, (kTileSize - kIconPixels) div 2, (kTileSize - kIconPixels) div 2, aHSizing, aVSizing, cicnTile, TRUE);
- itsIcon := theIcon;
-
- { Both itsPixMapPane and itsIcon are visible. We ensure that only one is drawn. }
-
- end; { IShTile }
-
-
- {****************************************************}
- {}
- { Free }
- {}
- { Destruction of the Showwit Tile object. We set our pointers to nil, for the }
- { objects to which they were pointing will be disposed of in inherited methods. }
- {}
- {****************************************************}
-
- procedure CShTile.Free;
-
- begin { Free }
- { The PixMap pane and icon are in the drawing heirarchy, }
- { and will be disposed of in the inherited methods. }
- itsPixMapPane := nil;
- itsIcon := nil;
-
- { The game director is the tile's supervisor. It will be }
- { disposed of in the inherited methods. Set our pointer }
- { to nil here. }
- itsGameDirector := nil;
-
- inherited Free;
- end; { Free }
-
-
- {****************************************************}
- {}
- { GetState }
- {}
- { Returns the current state of the tile, whether showing or hiding. }
- {}
- {****************************************************}
-
- function CShTile.GetState: TileState;
-
- begin { GetState }
- GetState := itsState;
- end; { GetState }
-
-
- {****************************************************}
- {}
- { GetState }
- {}
- { Sets the state of the tile to showing or hiding as appropriate. }
- {}
- {****************************************************}
-
- procedure CShTile.SetState (aState: TileState);
-
- begin { SetState }
- itsState := aState;
-
- { If this method is ever changed, then change DoFlip also. }
- end; { SetState }
-
-
- {****************************************************}
- {}
- { SetGridPos }
- {}
- { The position of the tile in the grid has been set. }
- {}
- {****************************************************}
-
- procedure CShTile.SetGridPos (aGridPos: TileRange);
-
- begin
- itsGridPos := aGridPos;
- end;
-
-
- {****************************************************}
- {}
- { SetTargetPICT }
- {}
- { Draw the target picture into the offscreen PixMap. }
- {}
- {****************************************************}
-
- procedure CShTile.SetTargetPICT (aPICTid: Integer);
-
- var
- targetPicture: PicHandle;
- savedAlloc: Boolean;
-
- tempRect: Rect;
-
- begin { SetTargetPICT }
- itsPixMapPane.BlitPICTRes(((itsGridPos - 1) mod kMaxGridAcross) * kTileSize, ((itsGridPos - 1) div kMaxGridAcross) * kTileSize, aPICTid, FALSE);
- end; { SetTargetPICT }
-
-
- {****************************************************}
- {}
- { DrawAll }
- {}
- { Draws either the hiding state or the target picture, as appropriate. }
- { Is essentially a pirate of the normal DrawAll method. }
- {}
- {****************************************************}
-
- procedure CShTile.DrawAll (var area: Rect);
-
- var
- tmpArea: Rect;
-
- ignore: Boolean;
-
- theRect: Rect;
- thePane: CPane; { PixMap or icon. }
-
- paneArea: Rect; { Area in Pane's Frame coords. }
- paneAperture: Rect;
-
- begin { DrawAll }
- tmpArea := area;
- Prepare;
-
- { area is in Window coordinates. Put it into Frame or QD coordinates. }
- if usingLongCoord then
- OffsetRect(tmpArea, thePort^.portRect.left, thePort^.portRect.top)
- else
- OffsetRect(tmpArea, hOrigin, vOrigin);
-
- ClipRect(tmpArea);
-
- { Need to draw a box to finish off tile for the icon. We don't need to }
- { erase the frame before drawing the picture, because the Draw }
- { procedure for the PixMap just CopyBits into place. The blitting }
- { procedure erases the offscreen PixMap before drawing the new picture. }
- if itsState = Hiding then begin
- LongToQDRect(frame, theRect);
- EraseRect(theRect);
-
- PenNormal;
- FrameRect(theRect);
- end; { if }
-
- { Clip area to aperture of this view before drawing subviews. }
- FrameToWindR(aperture, tmpArea);
- ignore := SectRect(tmpArea, area, tmpArea);
-
- if itsState = Hiding then begin
- thePane := itsIcon;
- end { if }
- else begin
- thePane := itsPixMapPane;
- end; { else }
-
- if thePane.ReallyVisible then begin
-
- { DrawAll always receives the area in Window coordinates. }
- { Since we are not printing, clip the area to the aperture. }
- thePane.FrameToWindR(thePane.aperture, paneAperture);
-
- { See if area intersects the aperture of the Pane to be drawn. }
- if SectRect(paneAperture, tmpArea, paneArea) then begin
- { Some portion of thePane must be drawn. }
- thePane.DrawAll(paneArea);
- end; { if }
- end; { if }
- end; { DrawAll }
-
-
- {****************************************************}
- {}
- { DoClick }
- {}
- { Sends a message to the game director to say that it has been clicked. }
- {}
- {****************************************************}
-
- procedure CShTile.DoClick (hitPt: Point;
- modifierKeys: integer;
- when: longint);
-
- begin { DoClick }
- itsGameDirector.DoTileClicked(itsGridPos);
- end; { DoClick }
-
-
- {****************************************************}
- {}
- { DoFlip }
- {}
- { Flips the tile, with animation and sound as appropriate. Sound on/off is }
- { controlled by SAT. }
- {}
- {****************************************************}
-
- procedure CShTile.DoFlip (aAnimate: Boolean);
-
- const
- kTickDelay = 1;
- kDivisions = 16;
-
- const
- kSATSoundPriority = 7;
-
- procedure LeftToRight;
-
- var
- theLRect: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { LeftToRight }
- GetFrame(theLRect);
- theLRect.Right := theLRect.Left;
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRect do begin
- Left := Right;
- Right := Left + theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRect, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { LeftToRight }
-
- procedure RightToLeft;
-
- var
- theLRect: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { RightToLeft }
- GetFrame(theLRect);
- theLRect.Left := theLRect.Right;
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRect do begin
- Right := Left;
- Left := Right - theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRect, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { RightToLeft }
-
- procedure TopToBottom;
-
- var
- theLRect: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { TopToBottom }
- GetFrame(theLRect);
- theLRect.Bottom := theLRect.Top;
-
- GetLengths(theWidth, theHeight);
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRect do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRect, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { TopToBottom }
-
- procedure BottomToTop;
-
- var
- theLRect: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { BottomToTop }
- GetFrame(theLRect);
- theLRect.Top := theLRect.Bottom;
-
- GetLengths(theWidth, theHeight);
- theHeight := theHeight div kDivisions;
-
- theOldTicks := TickCount;
- for theCounter := 1 to kDivisions do begin
- with theLRect do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRect, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { BottomToTop }
-
- procedure LeftUpRightDown;
-
- var
- theLRectLeft, theLRectRight: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { LeftUpRightDown }
- GetFrame(theLRectLeft);
- theLRectRight := theLRectLeft;
-
- with theLRectLeft do begin
- Top := Bottom;
- Right := (Left + Right) div 2;
- end; { with }
-
- with theLRectRight do begin
- Bottom := Top;
- Left := theLRectLeft.Right;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectLeft do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- end; { with }
-
- with theLRectRight do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectLeft, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectRight, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { LeftUpRightDown }
-
- procedure LeftDownRightUp;
-
- var
- theLRectLeft, theLRectRight: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { LeftDownRightUp }
- GetFrame(theLRectLeft);
- theLRectRight := theLRectLeft;
-
- with theLRectLeft do begin
- Bottom := Top;
- Right := (Left + Right) div 2; { Pane coordinates. }
- end; { with }
-
- with theLRectRight do begin
- Top := Bottom;
- Left := theLRectLeft.Right;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectLeft do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- end; { with }
-
- with theLRectRight do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectLeft, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectRight, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { LeftDownRightUp }
-
- procedure TopLRBottomRL;
-
- var
- theLRectTop, theLRectBottom: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { TopLRBottomRL }
- GetFrame(theLRectTop);
- theLRectBottom := theLRectTop;
-
- with theLRectTop do begin
- Right := Left;
- Bottom := (Top + Bottom) div 2; { Pane coordinates. }
- end; { with }
-
- with theLRectBottom do begin
- Left := Right;
- Top := theLRectTop.Bottom;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
-
- with theLRectTop do begin
- Left := Right;
- Right := Left + theWidth;
- end; { with }
-
- with theLRectBottom do begin
- Right := Left;
- Left := Right - theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectTop, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectBottom, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { TopLRBottomRL }
-
- procedure TopRLBottomLR;
-
- var
- theLRectTop, theLRectBottom: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { TopRLBottomLR }
- GetFrame(theLRectTop);
- theLRectBottom := theLRectTop;
-
- with theLRectTop do begin
- Left := Right;
- Bottom := (Top + Bottom) div 2; { Pane coordinates. }
- end; { with }
-
- with theLRectBottom do begin
- Right := Left;
- Top := theLRectTop.Bottom;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectTop do begin
- Right := Left;
- Left := Right - theWidth;
- end; { with }
-
- with theLRectBottom do begin
- Left := Right;
- Right := Left + theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectTop, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectBottom, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { TopRLBottomLR }
-
- procedure DiagTLtoBR;
-
- var
- theLRectVer, theLRectHor: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { DiagTLtoBR }
- GetFrame(theLRectVer);
- theLRectHor := theLRectVer;
-
- theLRectVer.botRight := theLRectVer.topLeft;
- theLRectHor.botRight := theLRectHor.topLeft;
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectVer do begin
- Left := Right;
- Right := Left + theWidth;
- Bottom := Bottom + theHeight;
- end; { with }
-
- with theLRectHor do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- Right := Right + theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectVer, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectHor, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { DiagTLtoBR }
-
- procedure DiagBRtoTL;
-
- var
- theLRectVer, theLRectHor: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { DiagBRtoTL }
- GetFrame(theLRectVer);
- theLRectHor := theLRectVer;
-
- theLRectVer.topLeft := theLRectVer.botRight;
- theLRectHor.topLeft := theLRectHor.botRight;
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectVer do begin
- Right := Left;
- Left := Right - theWidth;
- Top := Top - theHeight;
- end; { with }
-
- with theLRectHor do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- Left := Left - theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectVer, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectHor, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { DiagBRtoTL }
-
- procedure DiagTRtoBL;
-
- var
- theLRectVer, theLRectHor: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { DiagTRtoBL }
- GetFrame(theLRectVer);
- theLRectHor := theLRectVer;
-
- with theLRectVer do begin
- Bottom := Top;
- Left := Right;
- end; { with }
-
- with theLRectHor do begin
- Bottom := Top;
- Left := Right;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectVer do begin
- Right := Left;
- Left := Right - theWidth;
- Bottom := Bottom + theHeight;
- end; { with }
-
- with theLRectHor do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- Left := Left - theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectVer, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectHor, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { DiagTRtoBL }
-
- procedure DiagBLtoTR;
-
- var
- theLRectVer, theLRectHor: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { DiagBLtoTR }
- GetFrame(theLRectVer);
- theLRectHor := theLRectVer;
-
- with theLRectVer do begin
- Top := Bottom;
- Right := Left;
- end; { with }
-
- with theLRectHor do begin
- Top := Bottom;
- Right := Left;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions do begin
- with theLRectVer do begin
- Left := Right;
- Right := Left + theWidth;
- Top := Top - theHeight;
- end; { with }
-
- with theLRectHor do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- Right := Right + theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectVer, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectHor, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { DiagBLtoTR }
-
- procedure InwardsHor;
-
- var
- theLRectLeft, theLRectRight: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { InwardsHor }
- GetFrame(theLRectLeft);
- theLRectRight := theLRectLeft;
-
- theLRectLeft.Right := theLRectLeft.Left;
- theLRectRight.Left := theLRectRight.Right;
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
-
- for theCounter := 1 to kDivisions div 2 do begin
- with theLRectLeft do begin
- Left := Right;
- Right := Left + theWidth;
- end; { with }
- with theLRectRight do begin
- Right := Left;
- Left := Right - theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectLeft, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectRight, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { InwardsHor }
-
- procedure OutwardsHor;
-
- var
- theLRectLeft, theLRectRight: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { OutwardsHor }
- GetFrame(theLRectLeft);
- theLRectRight := theLRectLeft;
-
- with theLRectLeft do begin
- Right := (Left + Right) div 2;
- Left := Right;
- end; { with }
-
- with theLRectRight do begin
- Left := (Left + Right) div 2;
- Right := Left;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
-
- for theCounter := 1 to kDivisions div 2 do begin
- with theLRectLeft do begin
- Right := Left;
- Left := Right - theWidth;
- end; { with }
- with theLRectRight do begin
- Left := Right;
- Right := Left + theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectLeft, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectRight, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { OutwardsHor }
-
- procedure InwardsVer;
-
- var
- theLRectTop, theLRectBottom: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { InwardsVer }
- GetFrame(theLRectTop);
- theLRectBottom := theLRectTop;
-
- theLRectTop.Bottom := theLRectTop.Top;
- theLRectBottom.Top := theLRectBottom.Bottom;
-
- GetLengths(theWidth, theHeight);
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions div 2 do begin
- with theLRectTop do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- end; { with }
- with theLRectBottom do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectTop, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectBottom, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { InwardsVer }
-
- procedure OutwardsVer;
-
- var
- theLRectTop, theLRectBottom: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { OutwardsVer }
- GetFrame(theLRectTop);
- theLRectBottom := theLRectTop;
-
- with theLRectTop do begin
- Bottom := (Top + Bottom) div 2;
- Top := Bottom;
- end; { with }
-
- with theLRectBottom do begin
- Top := (Top + Bottom) div 2;
- Bottom := Top;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions div 2 do begin
- with theLRectTop do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- end; { with }
- with theLRectBottom do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectTop, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectBottom, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { OutwardsVer }
-
- procedure CentreIn;
-
- var
- theLRectLeft, theLRectTop, theLRectRight, theLRectBottom: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { CentreIn }
- GetFrame(theLRectLeft);
- theLRectTop := theLRectLeft;
- theLRectRight := theLRectLeft;
- theLRectBottom := theLRectLeft;
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
- theHeight := theHeight div kDivisions;
-
- with theLRectLeft do begin
- Right := Left;
- Top := Top - theHeight;
- Bottom := Bottom + theHeight;
- end; { with }
-
- with theLRectTop do begin
- Bottom := Top;
- Left := Left - theWidth;
- Right := Right + theWidth;
- end; { with }
-
- with theLRectRight do begin
- Left := Right;
- Top := Top - theHeight;
- Bottom := Bottom + theHeight;
- end; { with }
-
- with theLRectBottom do begin
- Top := Bottom;
- Left := Left - theWidth;
- Right := Right + theWidth;
- end; { with }
-
- for theCounter := 1 to kDivisions div 2 do begin
- with theLRectLeft do begin
- Left := Right;
- Right := Left + theWidth;
- Top := Top + theHeight;
- Bottom := Bottom - theHeight;
- end; { with }
- with theLRectTop do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- Left := Left + theWidth;
- Right := Right - theWidth;
- end; { with }
- with theLRectRight do begin
- Right := Left;
- Left := Right - theWidth;
- Top := Top + theHeight;
- Bottom := Bottom - theHeight;
- end; { with }
- with theLRectBottom do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- Left := Left + theWidth;
- Right := Right - theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectLeft, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectTop, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectRight, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectBottom, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { CentreIn }
-
- procedure CentreOut;
-
- var
- theLRectLeft, theLRectTop, theLRectRight, theLRectBottom: LongRect;
- theWidth, theHeight, theCounter: Integer;
-
- theOldTicks: LongInt;
-
- theQDRect: Rect;
-
- begin { CentreOut }
- GetFrame(theLRectLeft);
- theLRectTop := theLRectLeft;
- theLRectRight := theLRectLeft;
- theLRectBottom := theLRectLeft;
-
- with theLRectLeft do begin
- Right := (Left + Right) div 2;
- Bottom := (Top + Bottom) div 2;
- Left := Right;
- Top := Bottom;
- end; { with }
-
- with theLRectTop do begin
- Bottom := (Top + Bottom) div 2;
- Right := (Left + Right) div 2;
- Top := Bottom;
- Left := Right;
- end; { with }
-
- with theLRectRight do begin
- Left := (Left + Right) div 2;
- Bottom := (Top + Bottom) div 2;
- Right := Left;
- Top := Bottom;
- end; { with }
-
- with theLRectBottom do begin
- Top := (Top + Bottom) div 2;
- Right := (Left + Right) div 2;
- Bottom := Top;
- Left := Right;
- end; { with }
-
- GetLengths(theWidth, theHeight);
- theWidth := theWidth div kDivisions;
- theHeight := theHeight div kDivisions;
-
- for theCounter := 1 to kDivisions div 2 do begin
- with theLRectLeft do begin
- Right := Left;
- Left := Right - theWidth;
- Top := Top - theHeight;
- Bottom := Bottom + theHeight;
- end; { with }
- with theLRectTop do begin
- Bottom := Top;
- Top := Bottom - theHeight;
- Left := Left - theWidth;
- Right := Right + theWidth;
- end; { with }
- with theLRectRight do begin
- Left := Right;
- Right := Left + theWidth;
- Top := Top - theHeight;
- Bottom := Bottom + theHeight;
- end; { with }
- with theLRectBottom do begin
- Top := Bottom;
- Bottom := Top + theHeight;
- Left := Left - theWidth;
- Right := Right + theWidth;
- end; { with }
-
- theOldTicks := TickCount;
-
- FrameToWindR(theLRectLeft, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectTop, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectRight, theQDRect);
- DrawAll(theQDRect);
- FrameToWindR(theLRectBottom, theQDRect);
- DrawAll(theQDRect);
-
- while TickCount < theOldTicks + kTickDelay do begin { Nothing }
- end; { while }
-
- end; { for }
- end; { CentreOut }
-
- procedure FlipWithoutAnimation;
-
- var
- theLRect: LongRect;
- theQDRect: Rect;
-
- begin { FlipWithoutAnimation }
- GetFrame(theLRect);
- FrameToWindR(theLRect, theQDRect);
- DrawAll(theQDRect);
- end; { FlipWithoutAnimation }
-
- begin { DoFlip }
- if itsState = Hiding then begin
- itsState := Showing;
- end { if }
- else begin
- itsState := Hiding;
- end; { else }
-
- { Do sound first (asynchronously). }
- { SAT handles sound being on or off . }
-
- if gNumFlipSounds > 0 then begin
- {$PUSH}
- {$R-}
- SATSoundPlay(gFlipSoundHandles^^[Abs(Random) mod gNumFlipSounds + 1], kSATSoundPriority, TRUE);
- {$POP}
- end; { if }
-
- SATSoundEvents;
-
- if aAnimate then begin
- case Abs(Random) mod 18 of
- 0: begin
- LeftToRight;
- end; { 0 }
- 1: begin
- RightToLeft;
- end; { 1 }
- 2: begin
- TopToBottom;
- end; { 2 }
- 3: begin
- BottomToTop;
- end; { 3 }
- 4: begin
- LeftUpRightDown;
- end; { 4 }
- 5: begin
- LeftDownRightUp;
- end; { 5 }
- 6: begin
- TopLRBottomRL;
- end; { 6 }
- 7: begin
- TopRLBottomLR;
- end; { 7 }
- 8: begin
- DiagTLtoBR;
- end; { 8 }
- 9: begin
- DiagTRtoBL;
- end; { 9 }
- 10: begin
- DiagBRtoTL;
- end; { 10 }
- 11: begin
- DiagBLtoTR;
- end; { 11 }
- 12: begin
- InwardsHor;
- end; { 12 }
- 13: begin
- OutwardsHor;
- end; { 13 }
- 14: begin
- InwardsVer;
- end; { 12 }
- 15: begin
- OutwardsVer;
- end; { 13 }
- 16: begin
- CentreIn;
- end; { 12 }
- 17: begin
- CentreOut;
- end; { 13 }
- end; { case }
- end { if }
- else begin
- FlipWithoutAnimation;
- end; { else }
- end; { DoFlip }
-
-
- end. { CShTile }